package com.dhcc.bpm.modules.metadata.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.modules.metadata.entity.ServerApiMetadata;
import com.dhcc.bpm.modules.metadata.mapper.ServerApiMetadataMapper;
import com.dhcc.bpm.modules.metadata.service.IServerApiMetadataService;
import com.dhcc.bpm.modules.metadata.vo.ServerApiMetadataVO;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 接口定义数据表 服务实现类
 *
 * @author ccab
 * @since 2020-06-03
 */
@Service("opc_server_api_metadata")
public class ServerApiMetadataServiceImpl extends BaseServiceImpl<ServerApiMetadataMapper, ServerApiMetadata> implements IServerApiMetadataService {

	@Override
	public IPage<ServerApiMetadataVO> selectApiMetadataPage(IPage<ServerApiMetadataVO> page, ServerApiMetadataVO apiMetadata) {
		return page.setRecords(baseMapper.selectApiMetadataPage(page, apiMetadata));
	}
	@Override
	public List<ServerApiMetadataVO> tree() {
		return ForestNodeMerger.merge(baseMapper.tree());
	}

	@Override
	public List<ServerApiMetadata> findByGroupId(Long groupId) {
		return baseMapper.findByGroupId(groupId);
	}

	@Override
	public List<ServerApiMetadata> findOtherByApiId(Long apiId) {
		return baseMapper.findOtherByApiId(apiId);
	}

	@Override
	public List<ServerApiMetadata> findReqObjectByApiId(Long apiId) {
		return baseMapper.findReqObjectByApiId(apiId);
	}

	@Override
	public List<ServerApiMetadata> findChildByApiId(Long apiId, Long groupId) {
		return baseMapper.findChildByApiId(apiId, groupId);
	}

	@Override
	public ServerApiMetadata findByServerApiId(Long apiId, Long apiMetaDataId,String messageCheck) {
		return baseMapper.findByServerApiId(apiId,apiMetaDataId,messageCheck);
	}

	@Override
	public ServerApiMetadata findParentObjectByApiId(Long apiId) {
		return baseMapper.findParentObjectByApiId(apiId);
	}

	@Override
	public ServerApiMetadata findResObjectByApiId(Long apiId) {
		return baseMapper.findResObjectByApiId(apiId);
	}

	@Override
	public List<String> getApiIds(Long opcApiIdReq, String inType,Integer bodyType,Long parentId) {
		if(parentId == null) {
			parentId = 0L;
		}
		return baseMapper.getApiIds(opcApiIdReq, inType,bodyType,parentId);
	}
}
